#ifndef retrospec_game_car
#define retrospec_game_car

enum CarDirection {CAR_STRAIGHT,CAR_LEFT,CAR_RIGHT};
enum CarMovement {CAR_FREEWHEELING,CAR_ACCELERATE,CAR_DECELERATE};
enum CarStatus {CAR_NORMAL, CAR_DYING, CAR_DEAD};

class Car
{
public:
	static const int MAXVEL=10;
	static const int MAXVELTURBO=15;
	static const int MPH_MAX=500;
	static const int MPH_INCREASE=MPH_MAX/MAXVEL;
	static const int MPH_REDLINE=400;
	static const int MPH_YELLOWLINE=300;
	static const float FUEL_MAX;
	static const float FUEL_INC;
	Car() {	
			TemperatureLatch=false;
			screenx=screeny=angle=Mph=0;
			lastangle=-1;
			DamageLevel=32;
			acc=vel=decel=xdistancemoved=ydistancemoved=mapx=mapy=MilesDriven=0.0;
			Temperature=Fuel=TemperatureInc=TemperatureDec=0.0;
			car=NULL;
			BlockBadResponse=BlockTopSpeedIncrease=false;
			SpeedFactor=1.0;
			State=CAR_NORMAL;
			CarWidth=CarHeight=0;
			HitCar=false;
	}
	~Car();
	void SetupCar(std::string animtype,bool resetMiles);	//overridden by enemy cars, but we'll not make it virtual
	bool NextMove();			//overridden by enemy cars, but we'll not make it virtual
	
protected:
	void Accelerate();
	void Decelerate();
	void TurnRight();
	void TurnLeft();
	void CheckCollision();		//overridden by enemy cars, but we'll not make it virtual
	
public:
	AXL_Projects::Animation* car;
	bool HitCar;
	float acc;
	float vel;
	float decel;
	float mapx, mapy;			//real position in map
	int screenx,screeny;		//position to draw on the screen
	float MilesDriven;
	int angle;
	int lastangle;				//when handbrake, continue moving in same direction
								//but allow car to turn without affecting direction
	int Mph;
	float Fuel;
	float Temperature;
	CarStatus State;
	int DamageLevel;
	bool BlockTopSpeedIncrease;
	float SpeedFactor;
	int CarWidth;
	int CarHeight;
protected:
	float TemperatureInc;
	float TemperatureDec;
	float FuelUnit;
	bool Handbrake;
	float xdistancemoved,ydistancemoved;		//position moved
	CarMovement Move;
	CarDirection Direction;
	bool TemperatureLatch;
	bool BlockBadResponse;
};

/* path finding is as follows 
	1. car is activated if player is within 50 blocks (about 3 screens)
	2. path is created and incremented every few seconds using the animation timer
	3. increment time is a random figure between 1 and 3 seconds
	4. if outside range and path is active then it is closed and car is placed in a new place
	5. movement to be done
*/
class EnemyCar : public Car
{
public:
	void SetupCar();
	bool NextMove(Car* player);
	EnemyCar() { Route=NULL; }
	~EnemyCar() { if(Route) delete Route; }
	bool RouteGenerated;
	AstarClass* Route;
protected:
	void CheckCollision();
private:
};

#endif
